# encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')

class FT_8001:
    protocol=""#消息体
    result=[]
    analysis8001=["自定义消息体长度:", "应答流水号:", "应答ID:", "结果:"]
    analysis8001Length=[2,2,2,1]
    #protocolStr消息体（0900   8900 从数据长度之后的报文）
    #header数据长度之前解析的结果

    def LogicAisle(self,protocol,header):
        print protocol,header
        self.result=header
        print self.result
        count = 0
        for i in range(len(self.analysis8001)):
            if(i == (len(self.analysis8001) - 1)):
                respresult=protocol[count:count + (self.analysis8001Length[i]*2)]
                print respresult
                if (respresult=="00"):
                    self.result.append(self.analysis8001[i]  + "成功/确认"+ '\n' )
                    for i in range(len(self.result)):
                       print (i,self.result[i])
                elif (respresult=="01"):
                    self.result.append(self.analysis8001[i] + "失败" + '\n')
                    print ("class FT_8001:"+self.result[0])
                elif(respresult=="02"):
                    self.result.append(self.analysis8001[i] + "消息有误" + '\n')
                    print ("class FT_8001:"+self.result[0])
                elif(respresult=="03"):
                    self.result.append(self.analysis8001[i] + "不支持" + '\n')
                    print ("class FT_8001:"+self.result[0])
                elif(respresult=="04"):
                    self.result.append(self.analysis8001[i] + "报警处理确认" + '\n')
                    print ("class FT_8001:"+self.result[0])
                else:
                    print("LogicAisle")
            else:
                self.result.append(self.analysis8001[i] + protocol[count:count + (self.analysis8001Length[i]*2)]+ '\n')
                count = count + self.analysis8001Length[i]*2
                print ("class FT_8001:"+self.result[0])
